package com.qf.controller;

import com.qf.po.UserInfo;
import com.qf.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;
    @RequestMapping("/userinfos")
    public List<UserInfo> userInfos(){
        return userInfoService.finds();
    }
    @RequestMapping("/userinfo/{id}")
    public UserInfo userInfo(@PathVariable("id") Integer id){
        return userInfoService.find(id);
    }
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public UserInfo useradd(@RequestBody UserInfo userInfo){
        return userInfoService.add(userInfo);
    }
    @RequestMapping(value = "/upd",method = RequestMethod.PUT)
    public UserInfo update(@RequestBody UserInfo userInfo){
        return userInfoService.update(userInfo);
    }
    @RequestMapping(value = "/del/{id}",method = RequestMethod.DELETE)
    public boolean delete(@PathVariable("id") Integer id){
        return userInfoService.delete(id);
    }
}
